<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>英雄联盟抽奖</title>
    <link rel="stylesheet" href="__PUBLIC__/loldraw/css/style.css" />
    <style>

    </style>
</head>
<body>
<div class="bg">
    <div class="head">
        <div class="title">组团啦杯全国全国大学生英雄联盟比赛</div>
        <div class="full"><img src="__PUBLIC__/loldraw/img/full.png" alt="" id="fullclick"/></div>
    </div>
    <div class="bd">
        <div class="left">
            <div class="sm">
                <span class="bt">现场抽奖</span>
                <span class="num">共有1000人参与</span>
            </div>
            <div class="kuang">
                <img src="__PUBLIC__/loldraw/img/kuang.png"  alt=""/>
            </div>
            <div class="draw">
                <img src="" alt="" id="image"/>
            </div>
            <a href="#" class="but" id="btn">开始抽奖</a>
            <span class="hoster">主办方：组团啦高校社团服务平台</span>
            <div style="position: absolute; top: 78%; left: 3.5%;">
                <img src="__PUBLIC__/loldraw/img/erweima_03.jpg" alt="" width="120px"/>
            </div>
        </div>
        <div class="right">
            <p class="rule">抽奖规则</p>
            <p class="rule-word">参与在线投票的用户，并且关注“组团啦”微信官方平台。官方通过投票时提供的手机号联系并发送奖品。</p>
            <p class="rule">中奖名单</p>
            <ul id="luck">
                <!--<li><img src="__PUBLIC__/loldraw/img/2.jpg" alt="" /><span>微信名</span></li>-->
                <!--<li><img src="__PUBLIC__/loldraw/img/2.jpg" alt="" /><span>微信名</span></li>-->
                <!--<li><img src="__PUBLIC__/loldraw/img/2.jpg" alt="" /><span>微信名</span></li>-->
                <!--<li><img src="__PUBLIC__/loldraw/img/2.jpg" alt="" /><span>微信名</span></li>-->
                <!--<li><img src="__PUBLIC__/loldraw/img/2.jpg" alt="" /><span>微信名</span></li>-->
                <!--<li><img src="__PUBLIC__/loldraw/img/2.jpg" alt="" /><span>微信名</span></li>-->
                <!--<li><img src="__PUBLIC__/loldraw/img/2.jpg" alt="" /><span>微信名</span></li>-->
                <!--<li><img src="__PUBLIC__/loldraw/img/2.jpg" alt="" /><span>微信名</span></li>-->
                <!--<li><img src="__PUBLIC__/loldraw/img/2.jpg" alt="" /><span>微信名</span></li>-->
            </ul>
        </div>
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/loldraw/js/jquery-2.2.3.min.js" ></script>
<script type="text/javascript" src="__PUBLIC__/loldraw/js/jquery.fullscreen.js" ></script>
<script>
    var alldata=new Array();
    var allnickname= new Array();
    var allid = new Array();


    function initdata(){
        $.getJSON("{:U('getList')}?victory={$victory}",function(data){
            var data = data.info;
            alldata = new Array();
            allnickname= new Array();
            allid = new Array();
            for(var i=0;i<data.length;i++){
                alldata[i]  = data[i]['headimgurl'];
                allnickname[i] =data[i]['nickname'];
                allid[i] = data[i]['id'];
            }
        });
    }
    $(document).keypress(function(e) {
        // 回车键事件
        if(e.which == 13) {
            run();
        }
    });
    $(function(){
        initdata();

        $("#fullclick").click(function(){
            $(".bg").fullScreen();
            e.preventDefault();
        });
    })
    var open = false;  //抽将开关
    var randomVal=0;  //停留图片下标

    function change(){

        var num = alldata.length - 1;
        var show = $("#image");

        randomVal = Math.round(Math.random() * num);

        var prizeName = alldata[randomVal];
        show.attr("src",prizeName);
    }
    function run(){
        var btn =$("#btn");
        if(!open){
            <!-- 指定函数出现的速度，以毫秒计算-->
            timer=setInterval(change,20);
            btn.html('停止');
            open = true;
        }else{
            clearInterval(timer);
            btn.text('开始抽奖');
            open = false;
            $.getJSON("{:U('luck')}?id="+allid[randomVal],function(data){

            });
           var li =  $("#luck");

            var content = '<li><img src="'+alldata[randomVal]+'" alt="" /><span>'+allnickname[randomVal]+'</span></li>';
            li.append(content);
            alldata.remove(randomVal);
            allid.remove(randomVal);
            allnickname.remove(randomVal);

        }
    }
    Array.prototype.remove=function(obj){
        for(var i =0;i <this.length;i++){
            var temp = this[i];
            if(!isNaN(obj)){
                temp=i;
            }
            if(temp == obj){
                for(var j = i;j <this.length;j++){
                    this[j]=this[j+1];
                }
                this.length = this.length-1;
            }
        }
    }
</script>
</body>
</html>
